vim interactive mode AKA confirmation mode
In Vim, you can enter an interactive mode to replace blank lines one by one using “confirmation mode” in the :substitute command. Here’s how:
Command:
:g/^\s*$/c
Explanation:
-
:g/^\s*$/c
-
g → Applies the command to all matching lines.
-
/^\s*$/ → Matches blank lines (including those with spaces or tabs).
-
c → Asks for confirmation before replacing each match.
Interactive Mode:
After running the command, Vim will prompt you for each blank line with options like:
replace with:
Then, you can:
-
Type your new content and press Enter to replace the blank line.
-
Press n to skip that occurrence.
-
Press q to quit replacing.
-
Press a to replace all occurrences without further confirmation.
Would you like a variation with an actual replacement text?